
def abc():
    print("函数 abc 被调用")


# 列表的定义
l = [1, 2, 3, 4, 5, True, [7, 8, 9]]
# print(l)

l1 = list("abcdefg")

# 添加元素
l.append("张三")
# print(l)

l = ["李四", ] + l
# print(l)

l.extend(["赵六"])
# print(l)

l.insert(6, "王五")
# print(l)

# 列表的查询：索引、切片

# print(l[-5])
#
# print(l[3:5+1])
#
# print(l[8][0:1+1])


# 列表的更改

l[7] = False
# print(l)


# 列表元素的删除

# del l[-2]
# print(l)
#
# l.pop(6)
# print(l)
#
# l.pop()
# print(l)
#
#
# l.reverse()
print(l)


# for i in l:
#     if i == "张三":
#         print("欢迎张三")
#         break
# else:
#     print("没有")


# if "张三" in l:
#     print("欢迎张三")
# else:
#     print("没有")


# print(
#     "列表长度为：", len(l)
# )
#
# l2 = [1,2,3,6,8,5,4,61,6,5,1,65,16,56,5, -1, 0]
# print(
#     max(l2)
# )
# print(
#     min(l2)
# )


def is_o(n):
    return n % 3 == 0


# 列表推导式
lis = []
for i in range(10):
    if i % 2 == 0:
        lis.append(i)

print(lis)

lis2 = [x for x in range(10) if is_o(x)]
print(
    lis2
)

lis3 = [x if x % 2 == 0 else -1 for x in range(10)]
print(lis3)
